﻿////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// <copyright>Copyright 2008-2011 Andreas Huber Doenni</copyright>
// Distributed under the GNU General Public License version 2 (GPLv2).
// See accompanying file License.txt or copy at http://phuse.codeplex.com/license.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

namespace Phuse.TestServer
{
    using System;
    using System.ServiceModel;

    /// <summary>Represents a server that reacts to expected commands with predermined responses.</summary>
    [ServiceContract]
    internal interface IFakeServer
    {
        /// <summary>Starts the fake server.</summary>
        /// <param name="port">The port to listen for incomming connections.</param>
        /// <param name="greeting">The greeting to send after a connection has been established successfully.</param>
        /// <param name="disconnectAfterGreeting">The value <c>false</c> to listen for incomming commands after sending
        /// the greeting; <c>true</c> to disconnect right after sending the greeting.</param>
        [OperationContract]
        void Start(int port, byte[] greeting, bool disconnectAfterGreeting);

        /// <summary>Queues a sequence of bytes that are expected to be received on the connection together with the
        /// response that is sent as soon as the command has been received in full.</summary>
        [OperationContract]
        void QueueCommand(byte[] expectedCommand, byte[] response);

        /// <summary>Stops the fake server.</summary>
        [OperationContract]
        void Stop();
    }
}
